package cn.wen.rpc.balance;import com.alibaba.nacos.common.utils.RandomUtils;import lombok.extern.slf4j.Slf4j;import java.net.InetSocketAddress;import java.util.Optional;import java.util.Set;@Slf4jpublic class RandomLoadBalance implements LoadBalance{    @Override    public String name() {        return "random";    }    @Override    public InetSocketAddress loadBalance(Set<String> services) {        int size = services.size();        if (size <= 0) {            return null;        }        // 随机的负载均衡算法        int nextInt = RandomUtils.nextInt(0, size - 1);        Optional<String> optional = services.stream().skip(nextInt).findFirst();        if (optional.isPresent()){            String ipPort = optional.get();            return new InetSocketAddress(ipPort.split(",")[0], Integer.parseInt(ipPort.split(",")[1]));        }        return null;    }}